import '@babel/polyfill'
import Vue from 'vue'
import App from './App.vue'
import util from './libs/util'
import router from '@/router'
import store from './store/index'
import directive from './directive'
import filter from './filter'
import mixins from './mixins'
import api from './api'
import fetch from '@/utils/fetch'
// iconfont
import '@/assets/iconfont/iconfont'
// svg组件
import SvgIcon from 'components/svg-icon'
import VueBus from 'vue-bus'
// 监控组件
import MonitorCom from 'components/monitor-com'
import ImgCell from 'components/img-cell/index'
import FileUpload from 'components/file-upload'
import ImgUpload from 'components/img-upload'
// moment插件
import moment from 'vue-moment'
import { parseUrl } from '@/utils'
import './plugins/element.js'
// css
import './styles/lib/transition.scss'
import './resetCss'
import './styles/header-search.scss'
import './styles/layout.scss'
import './styles/tags-view.scss'
import './styles/common.scss'
import './styles/view.scss'
import './styles/width-img.scss'

import VueResource from 'vue-resource'
import VueRouter from 'vue-router';
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import DwUI from 'dw-ui'
import 'dw-ui/lib/theme-chalk/index.css'

// 认证
import './auth'
Vue.config.productionTip = false

directive.init()
filter.init()
mixins.init()


Vue.component(SvgIcon.name, SvgIcon)
Vue.component(MonitorCom.name, MonitorCom)
Vue.component(ImgCell.name, ImgCell)
Vue.component(FileUpload.name, FileUpload)
Vue.component(ImgUpload.name, ImgUpload)
Vue.use(moment)
Vue.use(VueBus)

Vue.use(VueResource)
Vue.use(VueRouter)
Vue.use(ViewUI)

Vue.use(ElementUI)
Vue.use(DwUI)

// 全局引入api
Vue.prototype.api = api
Vue.prototype.$fetch = fetch
const isRedictByLogin = () => {
    const params = parseUrl()
    return !!params.uas_st
}

const redirectUrl = store.getters.redirectUrl
if (isRedictByLogin()) {
    const url = redirectUrl
        ? decodeURIComponent(redirectUrl)
        : window.location.origin
    store.dispatch('app/setRedirectUrl', '')
    window.location.href = decodeURIComponent(url)
} else {
    new Vue({
        router,
        store,
        render: (h) => h(App)
    }).$mount('#app')
}
